//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "CDBLklb.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
#define COL_DISABLE       clBtnFace
#define COL_DISABLE_TEXT  clBtnShadow
//---------------------------------------------------------------------------
// ValidCtrCheck est utilisé pour être sûr que les composants créés ne
// contiennent aucune fonction virtuelle pure.
//

static inline void ValidCtrCheck(CDBLookupListBox *)
{
    new CDBLookupListBox(NULL);
}
//---------------------------------------------------------------------------
__fastcall CDBLookupListBox::CDBLookupListBox(TComponent* Owner)
    : TDBLookupListBox(Owner)
{
  m_asRefWebHelp = EmptyStr;
  m_Enabled      = true;
  m_ReadOnly     = false;
  m_Color        = clWindow;
  m_Font         = NULL;

  try {
    m_Font = new TFont;
  } catch (...) {
  }
}
//---------------------------------------------------------------------------
__fastcall CDBLookupListBox::~CDBLookupListBox()
{
  delete m_Font;
}
//---------------------------------------------------------------------------
void __fastcall CDBLookupListBox::SetEnabled(bool value)
{
  m_Enabled                 = value;
  TDBLookupListBox::Enabled = value;
  Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall CDBLookupListBox::SetReadOnly(bool value)
{
  m_ReadOnly                 = value;
  TDBLookupListBox::ReadOnly = value;
  Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall CDBLookupListBox::SetColor(TColor value)
{
  m_Color = value;
  Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall CDBLookupListBox::SetFont(TFont *value)
{
  m_Font->Assign(value);
}
//---------------------------------------------------------------------------
void __fastcall CDBLookupListBox::EvOnChange(TObject *Sender)
{
  Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall CDBLookupListBox::WMPaint(TWMPaint &Msg)
{
  TDBLookupListBox::Font->Assign(m_Font);
  TDBLookupListBox::Font->Color = (m_Enabled ? m_Font->Color : COL_DISABLE_TEXT);
  TDBLookupListBox::Color       = ((!m_Enabled || m_ReadOnly) ? COL_DISABLE : m_Color);
  TDBLookupListBox::Dispatch(&Msg);
}
//---------------------------------------------------------------------------
namespace Cdblklb
{
    void __fastcall PACKAGE Register()
    {
        TComponentClass classes[1] = {__classid(CDBLookupListBox)};
        RegisterComponents("EIC CtrlDB", classes, 0);
    }
}
//---------------------------------------------------------------------------
void __fastcall CDBLookupListBox::KeyDown( Word &Key, TShiftState Shift)
{
      //WebHelp
      //-------
      if( (Key == VK_F3) && (Shift.Contains( ssCtrl )) ) {
            AccesWebHelp( m_asRefWebHelp );
      }else {
          if( Key == VK_F3 ) 
            VerifierRefWebHelp( m_asRefWebHelp );
      }
}
//---------------------------------------------------------------------------
